home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Cookie / todo-list.izs < prev    next >
Text File  |  2005-09-28  |  8KB  |  289 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>To Do List 
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>This script shows you how you can create a to do list. it adds the list to a cookie fill so that when you view again it is still there!<!/DESCRIPTION> 
  7.  
  8. <!CATEGORY>cookies<!/CATEGORY>
  9.  
  10. <!SCRIPT>
  11. <!-- START OF SCRIPT -->
  12.  
  13. <!-- HOW TO INSTALL TO DO LIST:
  14.  
  15.   1.  Copy code into the HEAD section of document
  16.   2.  Put last coding into the BODY section of document  -->
  17.  
  18. <!-- STEP ONE: Add code into HEAD section of document  -->
  19.  
  20. <HEAD>
  21.  
  22. <SCRIPT LANGUAGE="JavaScript">
  23. <!-- Original:  Pete Thompson (thompp@globalnet.co.uk) -->
  24. <!-- Web Site:  http://www.users.globalnet.co.uk/~thompp -->
  25.  
  26.  
  27. <!-- Begin
  28. var expDays = 30;
  29. var exp = new Date(); 
  30. exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
  31. var ShowCount = 0;
  32. var SwapColour;
  33. function ListToDoItems() {
  34. var NumToDoItems = GetCookie('PT_NumToDoList');
  35. var i;
  36. var ToDoItem;
  37. if (NumToDoItems == null) {
  38. NumToDoItems = 0;
  39. }
  40. ShowCount = 0; SwapColour = 0;
  41. for (i=1; i <= NumToDoItems; i++) {
  42. ToDoItem = GetCookie('PT_ToDoItem'+i);
  43. if (ToDoItem != null) {
  44. PrintItem(ToDoItem, i);
  45.       }
  46.    }
  47. }
  48. function DeleteItem(Count) {
  49. DeleteCookie('PT_ToDoItem'+Count);
  50. window.location = window.location;
  51. }
  52. function PrintItem (ToDoItem, Count) {
  53. var color = "";
  54. SwapColour = 1 - SwapColour;
  55. if (SwapColour==1) {color = "bgcolor='#c0c0c0'"} ;
  56. ShowCount++;
  57. document.write("<tr " + color + ">");
  58. document.write("<td width=10% align=center valign=top><small><b>"+ShowCount);
  59. document.write("<td width=75% align=left  ><small>"+ToDoItem);
  60. document.write("<td width=15% align=center><small>"+"<a href='javascript:DeleteItem(" + Count + ")'>Delete</a>");
  61. }
  62. function AddItem() {
  63. var NumToDoItems = GetCookie('PT_NumToDoList');
  64. var i;
  65. var ToDoItem;
  66. if (NumToDoItems == null) {
  67. NumToDoItems = 0;
  68. }
  69. ToDoItem = prompt("Enter new item");
  70. if ((ToDoItem != null) && (ToDoItem != "undefined" )) {
  71. NumToDoItems++;
  72. SetCookie('PT_ToDoItem'+NumToDoItems, ToDoItem, exp);
  73. SetCookie('PT_NumToDoList',NumToDoItems, exp);
  74. window.location = window.location;
  75.    }
  76. }
  77. function set() {
  78. VisitorName = prompt("Who are you?");
  79. SetCookie ('VisitorName', VisitorName, exp);
  80. SetCookie ('WWHCount', 0, exp);
  81. SetCookie ('WWhenH', 0, exp);
  82. }
  83. function getCookieVal (offset) {  
  84. var endstr = document.cookie.indexOf (";", offset);  
  85. if (endstr == -1)    
  86. endstr = document.cookie.length;  
  87. return unescape(document.cookie.substring(offset, endstr));
  88. }
  89. function GetCookie (name) {  
  90. var arg = name + "=";  
  91. var alen = arg.length;  
  92. var clen = document.cookie.length;  
  93. var i = 0;  
  94. while (i < clen) {    
  95. var j = i + alen;    
  96. if (document.cookie.substring(i, j) == arg)      
  97. return getCookieVal (j);    
  98. i = document.cookie.indexOf(" ", i) + 1;    
  99. if (i == 0) break;   
  100. }  
  101. return null;
  102. }
  103. function SetCookie (name, value) {  
  104. var argv = SetCookie.arguments;  
  105. var argc = SetCookie.arguments.length;  
  106. var expires = (argc > 2) ? argv[2] : null;  
  107. var path = (argc > 3) ? argv[3] : null;  
  108. var domain = (argc > 4) ? argv[4] : null;  
  109. var secure = (argc > 5) ? argv[5] : false;  
  110. document.cookie = name + "=" + escape (value) + 
  111. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
  112. ((path == null) ? "" : ("; path=" + path)) +  
  113. ((domain == null) ? "" : ("; domain=" + domain)) +    
  114. ((secure == true) ? "; secure" : "");
  115. }
  116. function DeleteCookie (name) {  
  117. var exp = new Date();  
  118. exp.setTime (exp.getTime() - 1);  
  119. var cval = GetCookie (name);  
  120. document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  121. }
  122. //  End -->
  123. </script>
  124.  
  125. </HEAD>
  126.  
  127. <!-- STEP TWO: Add code into BODY section of document  -->
  128.  
  129. <BODY>
  130.  
  131. <b><center><big>To Do List</big><center></b>
  132. <hr><br>
  133. <table width=100%>
  134. <SCRIPT LANGUAGE="JavaScript">
  135. <!-- Begin
  136. ListToDoItems();
  137. //  End -->
  138. </SCRIPT>
  139. </table>
  140. <br><hr>
  141. <center>
  142. <a href="javascript:AddItem()">Add Item</a>
  143. </center>
  144.  
  145. <!-- END OF SCRIPT -->
  146. <!/SCRIPT>
  147.  
  148. <!PREVIEW>
  149. <!-- START OF SCRIPT -->
  150.  
  151.  
  152.  
  153. <!-- HOW TO INSTALL TO DO LIST:
  154.  
  155.   1.  Copy code into the HEAD section of document
  156.   2.  Put last coding into the BODY section of document  -->
  157.  
  158. <!-- STEP ONE: Add code into HEAD section of document  -->
  159.  
  160. <HEAD>
  161.  
  162. <SCRIPT LANGUAGE="JavaScript">
  163. <!-- Original:  Pete Thompson (thompp@globalnet.co.uk) -->
  164. <!-- Web Site:  http://www.users.globalnet.co.uk/~thompp -->
  165.  
  166.  
  167. <!-- Begin
  168. var expDays = 30;
  169. var exp = new Date(); 
  170. exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
  171. var ShowCount = 0;
  172. var SwapColour;
  173. function ListToDoItems() {
  174. var NumToDoItems = GetCookie('PT_NumToDoList');
  175. var i;
  176. var ToDoItem;
  177. if (NumToDoItems == null) {
  178. NumToDoItems = 0;
  179. }
  180. ShowCount = 0; SwapColour = 0;
  181. for (i=1; i <= NumToDoItems; i++) {
  182. ToDoItem = GetCookie('PT_ToDoItem'+i);
  183. if (ToDoItem != null) {
  184. PrintItem(ToDoItem, i);
  185.       }
  186.    }
  187. }
  188. function DeleteItem(Count) {
  189. DeleteCookie('PT_ToDoItem'+Count);
  190. window.location = window.location;
  191. }
  192. function PrintItem (ToDoItem, Count) {
  193. var color = "";
  194. SwapColour = 1 - SwapColour;
  195. if (SwapColour==1) {color = "bgcolor='#c0c0c0'"} ;
  196. ShowCount++;
  197. document.write("<tr " + color + ">");
  198. document.write("<td width=10% align=center valign=top><small><b>"+ShowCount);
  199. document.write("<td width=75% align=left  ><small>"+ToDoItem);
  200. document.write("<td width=15% align=center><small>"+"<a href='javascript:DeleteItem(" + Count + ")'>Delete</a>");
  201. }
  202. function AddItem() {
  203. var NumToDoItems = GetCookie('PT_NumToDoList');
  204. var i;
  205. var ToDoItem;
  206. if (NumToDoItems == null) {
  207. NumToDoItems = 0;
  208. }
  209. ToDoItem = prompt("Enter new item");
  210. if ((ToDoItem != null) && (ToDoItem != "undefined" )) {
  211. NumToDoItems++;
  212. SetCookie('PT_ToDoItem'+NumToDoItems, ToDoItem, exp);
  213. SetCookie('PT_NumToDoList',NumToDoItems, exp);
  214. window.location = window.location;
  215.    }
  216. }
  217. function set() {
  218. VisitorName = prompt("Who are you?");
  219. SetCookie ('VisitorName', VisitorName, exp);
  220. SetCookie ('WWHCount', 0, exp);
  221. SetCookie ('WWhenH', 0, exp);
  222. }
  223. function getCookieVal (offset) {  
  224. var endstr = document.cookie.indexOf (";", offset);  
  225. if (endstr == -1)    
  226. endstr = document.cookie.length;  
  227. return unescape(document.cookie.substring(offset, endstr));
  228. }
  229. function GetCookie (name) {  
  230. var arg = name + "=";  
  231. var alen = arg.length;  
  232. var clen = document.cookie.length;  
  233. var i = 0;  
  234. while (i < clen) {    
  235. var j = i + alen;    
  236. if (document.cookie.substring(i, j) == arg)      
  237. return getCookieVal (j);    
  238. i = document.cookie.indexOf(" ", i) + 1;    
  239. if (i == 0) break;   
  240. }  
  241. return null;
  242. }
  243. function SetCookie (name, value) {  
  244. var argv = SetCookie.arguments;  
  245. var argc = SetCookie.arguments.length;  
  246. var expires = (argc > 2) ? argv[2] : null;  
  247. var path = (argc > 3) ? argv[3] : null;  
  248. var domain = (argc > 4) ? argv[4] : null;  
  249. var secure = (argc > 5) ? argv[5] : false;  
  250. document.cookie = name + "=" + escape (value) + 
  251. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
  252. ((path == null) ? "" : ("; path=" + path)) +  
  253. ((domain == null) ? "" : ("; domain=" + domain)) +    
  254. ((secure == true) ? "; secure" : "");
  255. }
  256. function DeleteCookie (name) {  
  257. var exp = new Date();  
  258. exp.setTime (exp.getTime() - 1);  
  259. var cval = GetCookie (name);  
  260. document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  261. }
  262. //  End -->
  263. </script>
  264.  
  265. </HEAD>
  266.  
  267. <!-- STEP TWO: Add code into BODY section of document  -->
  268.  
  269. <BODY>
  270.  
  271. <b><center><big>To Do List</big><center></b>
  272. <hr><br>
  273. <table width=100%>
  274. <SCRIPT LANGUAGE="JavaScript">
  275. <!-- Begin
  276. ListToDoItems();
  277. //  End -->
  278. </SCRIPT>
  279. </table>
  280. <br><hr>
  281. <center>
  282. <a href="javascript:AddItem()">Add Item</a>
  283. </center>
  284.  
  285. <!-- END OF SCRIPT -->
  286. <!/PREVIEW>
  287.  
  288. <!RELATED>NONE<!/RELATED>
  289.